package com.guli.sms.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.guli.common.pojo.SeckillSkuRelationEntity;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guli.sms.vo.SeckillSkuRelationWithNamesVo;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * 秒杀活动商品关联
 *
 * @author LuoJunHua
 * @email 1007052116@qq.com
 * @date 2020-11-29 10:59:49
 */
public interface SeckillSkuRelationService extends IService<SeckillSkuRelationEntity> {

    Page<SeckillSkuRelationWithNamesVo> queryPage(Integer currentPage, Integer size, Long sessionId) throws ExecutionException, InterruptedException;

    Page<SeckillSkuRelationEntity> getSeckillRelationsBySeckillSessionId(long seckillSessionId, Integer currentPage, long size);

    List<SeckillSkuRelationEntity> getSeckillRelationsBySeckillSessionId(Long sessionId);

    /**
     * 删除关联的同时，要使缓存失效
     * @param relationIds
     */
    void removeByIdsAndInvalidCache(List<Long> relationIds);

    /**
     * 批量保存 relation，并且判断保存的场次是否在近期有秒杀活动，如果监测到
     * 这个秒杀活动已经写入到redis，就要写入之后刷新redis
     * @param seckillSkuRelationList
     */
    void saveBatchAndCheckIfRedisNeedesToRefresh(List<SeckillSkuRelationEntity> seckillSkuRelationList);

    void saveBatchWithLocalTransactional(List<SeckillSkuRelationEntity> seckillSkuRelationList);

    void deleteBatchIdsWithTransactional(List<Long> relationIds);

    void updateByIdAndCheckIfRedisNeedesToRefresh(SeckillSkuRelationEntity seckillSkuRelation);
}

